﻿CREATE TABLE [dbo].[arhConturi] (
    [Cont]            [dbo].[TipCont] DEFAULT ('') NOT NULL,
    [CodUnitate]      SMALLINT        DEFAULT ((0)) NOT NULL,
    [Denumire]        VARCHAR (200)   DEFAULT ('') NOT NULL,
    [Tip]             CHAR (1)        DEFAULT ('A') NOT NULL,
    [Terminal]        BIT             DEFAULT ((1)) NOT NULL,
    [ContParinte]     [dbo].[TipCont] DEFAULT ('') NOT NULL,
    [EsteAnalitic]    BIT             DEFAULT ((1)) NOT NULL,
    [DebitInitial]    DECIMAL (20, 2) DEFAULT ((0)) NOT NULL,
    [CreditInitial]   DECIMAL (20, 2) DEFAULT ((0)) NOT NULL,
    [DebitPrecedent]  DECIMAL (20, 2) DEFAULT ((0)) NOT NULL,
    [CreditPrecedent] DECIMAL (20, 2) DEFAULT ((0)) NOT NULL,
    [Categorie]       TINYINT         DEFAULT ((0)) NOT NULL,
    [RulajDebit]      DECIMAL (20, 2) DEFAULT ((0)) NOT NULL,
    [RulajCredit]     DECIMAL (20, 2) DEFAULT ((0)) NOT NULL,
    [Sold]            DECIMAL (20, 2) DEFAULT ((0)) NOT NULL,
    [SortValue]       [dbo].[TipCont] DEFAULT ('') NOT NULL,
    [An]              SMALLINT        DEFAULT ((0)) NOT NULL,
    CONSTRAINT [PK_arhConturi] PRIMARY KEY CLUSTERED ([Cont] ASC, [CodUnitate] ASC, [An] ASC),
    CONSTRAINT [CK_arhConturi_Tip] CHECK ([Tip]='A' OR [Tip]='P' OR [Tip]='B'),
    CONSTRAINT [FK_arhConturi_arhConturi] FOREIGN KEY ([ContParinte], [CodUnitate], [An]) REFERENCES [dbo].[arhConturi] ([Cont], [CodUnitate], [An]),
    CONSTRAINT [FK_arhConturi_Unitati] FOREIGN KEY ([CodUnitate]) REFERENCES [dbo].[Unitati] ([CodUnitate])
);

